<%@ include file="connect.jsp" %>
<%@ page import="java.sql.ResultSet" %>
<%--
  Created by IntelliJ IDEA.
  User: Calvin
  Date: 12/2/12
  Time: 11:32 AM
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Edit Learn</title>
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript" src="jquery.leanModal.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#newmaterial").leanModal({ top:200, closeButton:".modal_close" });
        });
    </script>
    <link href="style.css" rel="stylesheet"/>
    <script type="text/javascript" language="javascript">
        function confirmAction() {
            var confirmed = confirm("Are you sure want to delete this word?");
            return confirmed;
        }
    </script>
    <script src="jquery.js" type="text/javascript"></script>
    <script src="facebox.js" type="text/javascript"></script>
    <script type="text/javascript">
        jQuery(document).ready(function ($) {
            $('a[rel*=facebox]').facebox({
                loadingImage:'images/loading.gif',
                closeImage:'images/closelabel.png'
            })
        })
    </script>
    <script type="text/javascript">
        function validasi() {

        }
    </script>
</head>
<body>
<table id="bg" cellspacing="0">
    <tr id="header">

        <td class="link">
            <%@ include file="header.jsp" %>
        </td>
    </tr>
    <tr id="menu">
        <td>
            <%@ include file="menu.jsp" %>
        </td>
    </tr>
    <tr id="hr">
        <td><hr width="100%" size="8" noshade="noshade" ></td>
    </tr>
    <tr id="content">
        <td class="link" valign="top" style="padding-left: 20px">
            <table>

                <tr id="title">
                    <td>Learn >> Material's Detail</td>
                </tr>


                <%
                    String learnId = request.getParameter("id");
                    String para = "";
                    ResultSet rs = stat.executeQuery("select * from learn where learnid = " + learnId);
                    if (rs.next()) {
                        para = rs.getString("Paragraph");

                    }
                %>
                <table>
                    <tr>
                        <td>
                            <div class="btn-fld">
                                <a id="newmaterial" rel="facebox" name="signup" href="addNewWord.jsp?id=<%=learnId%>">
                                    <button type="button">Add New Word</button>
                                </a>
                            </div>
                        </td>
                    </tr>
                </table>
                <table>
                    <tr id="warning">
                        <td>

                            <%
                                String respon = request.getParameter("respon");

                                if (respon != null) {

                                    out.print(respon + " ");
                                } %>
                        </td>
                    </tr>
                </table>

                    <table id="paragraf">
                        <tr>
                            <td><textarea cols="75" id="para" name="para" readonly="readonly" ><%=para%>
                            </textarea></td>
                        </tr>

                        <tr>
                            <td align="right">
                                <div class="btn-fld">
                                    <a  rel="facebox" href="EditPara.jsp?id=<%=learnId%>">
                                        <button type="button">Update Paragraph</button></a>
                                </div>
                            </td>
                        </tr>
                    </table>
                </br>



                <table width="980px" id="bor1" border="2">
                    <tr align="center" style="text-align: center; font-weight: 600">
                        <td>No</td>
                        <td>Words</td>
                        <td>Definition</td>
                        <td>Images</td>
                        <td>Example</td>
                        <td>Part of Speech</td>
                        <td>Word Stem</td>
                        <td style="width: 70px">Action</td>
                    </tr>
                    <tr>
                        <%

                            int i = 0;
                            rs = stat.executeQuery("select * from learn a, detailLearn b where a.learnid= b.learnid and a.learnid = " + learnId);
                            while (rs.next()) {
                                i = i + 1;
                                String id = rs.getString("detailLearnID");
                        %>
                        <td align="center"><%=i%>
                        </td>
                        <td><%out.print(rs.getString("words"));%></td>
                        <td><%out.print(rs.getString("definition"));%></td>
                        <td><%out.print(rs.getString("images"));%></td>
                        <td><%out.print(rs.getString("example"));%></td>
                        <td><%out.print(rs.getString("partofspeech"));%></td>
                        <td><%out.print(rs.getString("wordstem"));%></td>
                        <td align="center"><a href="editWord.jsp?id=<%=id%>&learn=<%=learnId%>" rel="facebox">
                            <img height="25px" src="edit.png" title="Edit Word"></a>
                            <a href="doDeleteWord.jsp?id=<%=id%>&words=<%=rs.getString("words")%>&learn=<%=learnId%>"
                               onclick="return confirmAction()"><img height="25px" src="Delete.png"
                                                                     title="Delete Material"></a></td>
                    </tr>
                    <% }
                        conn.close();
                    %>

                </table>


            </table>
        </td>
    </tr>


</table>
</body>
</html>